package com.tgy.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 * @Author: tgy
 * @Date: 2020-08-21 16:47
 */
@Controller
public class Demo01Controller {

    @GetMapping("/test01")
    public String test01(RedirectAttributes redirectAttributes){

        redirectAttributes.addFlashAttribute("name","张三");

        return "redirect:/test02";
    }

    @GetMapping("/test02")
    @ResponseBody
    public String test02(@ModelAttribute("name")String name){

        return name;
    }
}
